var ReportUser = {

    selected_row_id:null,
    objGrid:null,

    init:function () {
        var self = this;

        $("#form-query #user").change(function(){
            var text  = $("#form-query #user option:selected").text();
            $("#form-query #user_name").val(text);
        });
        $("#form-query #user").change();

        $("#form-query #priority").change(function(){
            var text  = $("#form-query #priority option:selected").text();
            $("#form-query #priority_name").val(text);
        });
        $("#form-query #priority").change();

        $("#form-query #project").change(function(){
            var text  = $("#form-query #project option:selected").text();
            $("#form-query #project_name").val(text);
        });
        $("#form-query #project").change();

        $("#form-query #department").change(function(){
            var text  = $("#form-query #department option:selected").text();
            $("#form-query #department_name").val(text);
        });
        $("#form-query #department").change();

        $("#form-query #branch").change(function(){
            var text  = $("#form-query #branch option:selected").text();
            $("#form-query #branch_name").val(text);
        });
        $("#form-query #branch").change();



        $("#export-btn").click(function () {
            self.print_export_Details('export');
        });
        $("#print-btn").click(function () {
            self.print_export_Details('print');
        });
    },

    print_export_Details: function(data_type){
        $("#print-export-form #data_type").val(data_type);
        $("#print-export-form #data_start_dt").val($("#form-query #start_dt").val());
        $("#print-export-form #data_end_dt").val($("#form-query #end_dt").val());
        $("#print-export-form #data_user").val($("#form-query #user").val());
        $("#print-export-form #data_user_name").val($("#form-query #user option:selected").text());
        $("#print-export-form #data_priority").val($("#form-query #priority").val());
        $("#print-export-form #data_priority_name").val($("#form-query #priority option:selected").text());
        $("#print-export-form #data_project").val($("#form-query #project").val());
        $("#print-export-form #data_project_name").val($("#form-query #project option:selected").text());
        $("#print-export-form #data_department").val($("#form-query #department").val());
        $("#print-export-form #data_department_name").val($("#form-query #department option:selected").text());
        $("#print-export-form #data_branch").val($("#form-query #branch").val());
        $("#print-export-form #data_branch_name").val($("#form-query #branch option:selected").text());

        window.open('', "PrintExportWindow", "menubar=yes, width=600, height=500,location=no,status=no,scrollbars=yes,resizable=yes");
        $("#print-export-form").submit();
    }

};

/* when the page is loaded */
$(document).ready(function () {
    ReportUser.init();
});